package com.wyh.book.model;

import com.wyh.book.enums.ResultCodeEnum;
import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 王圆豪
 * Date: 2025-07-14
 * Time: 15:02
 */
@Data
public class Result<T> {
    private T data;
    private ResultCodeEnum code;
    private String errMsg;

    public static <T> Result success(T data){
        Result<T> result = new Result<>();
        result.setCode(ResultCodeEnum.SUCCESS);
        result.setData(data);
        result.setErrMsg("");
        return result;
    }

    public static <T> Result fail(T data){
        Result result = new Result<>();
        result.setCode(ResultCodeEnum.FAIL);
        result.setData(data);
        result.setErrMsg("失败！");
        return result;
    }

    public static <T> Result unLogin(T data){
        Result result = new Result<>();
        result.setCode(ResultCodeEnum.UNLOGIN);
        result.setData(data);
        result.setErrMsg("用户未登录！");
        return result;
    }
}
